<?php
namespace app\index\controller;
use FormBuilder\Factory\Elm;
use FormBuilder\Form\IviewForm;
use think\facade\Cache;
use app\admin\controller\Base;
use FormBuilder\Form;

class Index
{
    public function index()
    {

        $action = '/save.php';
        $method = 'POST';
        
        
        $input = Elm::input('goods_name', '商品名称')->required();
        $input1 = Elm::input('goods_name1', '商品名称')->required();
        $textarea = Elm::textarea('goods_info', '商品简介');
        $switch = Elm::switches('is_open', '是否开启')->activeText('开启111')->inactiveText('关闭1');
        $text = Elm::text('field', 'title');
//创建表单
        $form = (new IviewForm($action))->setMethod($method);
//        $form = Elm::form($action)->setMethod($method);
        $form->setTitle('商品编辑');
//添加组件
        
        $form->setRule([$input, $textarea]);
        $form->append($switch);
        $form->append($input1);
        $form->append($text);

//生成表单页面
        echo $formHtml = $form->view();
    }

    public function hello($name = 'ThinkPHP5')
    {
        $model = model('advert');
        dump($model->find());
    }
}
